#!/bin/bash

## You should change the "BuildTest" script so that this can BuildTest your test code.

## Assumes you have a file "disk1.original" which is a "bare" file system: Initialized with a free list
## and an empty directory. All of these tests are hard coded to use a disk with name "disk1". "disk1.original"

diskOrig="disk1.original"
disk="disk1"
TestsDir="Tests"
OutputDir="output"

# make a backup
cp ${diskOrig} ${disk}.copy

./BuildTest ${TestsDir}/Test1.cpp
echo "Running test 1"
cp ${disk}.copy ${disk} 
${TestsDir}/Test1 > ${OutputDir}/output1
grep --ignore-case ERROR < ${OutputDir}/output1

./BuildTest ${TestsDir}/Test2a.cpp
echo "Running test 2a"
cp ${disk}.copy ${disk} 
${TestsDir}/Test2a > ${OutputDir}/output2a
grep --ignore-case ERROR < ${OutputDir}/output2a

./BuildTest ${TestsDir}/Test2b.cpp
echo "Running test 2b"
cp ${disk}.copy ${disk} 
${TestsDir}/Test2b > ${OutputDir}/output2b
grep --ignore-case ERROR < ${OutputDir}/output2b

./BuildTest ${TestsDir}/Test3.cpp
echo "Running test 3"
cp ${disk}.copy ${disk} 
${TestsDir}/Test3 > ${OutputDir}/output3
grep --ignore-case ERROR < ${OutputDir}/output3

./BuildTest ${TestsDir}/Test4.cpp
echo "Running test 4"
cp ${disk}.copy ${disk} 
${TestsDir}/Test4 > ${OutputDir}/output4.1
grep --ignore-case ERROR < ${OutputDir}/output4.1
${TestsDir}/Test4 secondPart > ${OutputDir}/output4.2
grep --ignore-case ERROR < ${OutputDir}/output4.2

./BuildTest ${TestsDir}/Test5a.cpp
echo "Running test 5a"
cp ${disk}.copy ${disk} 
${TestsDir}/Test5a > ${OutputDir}/output5a.1
grep --ignore-case ERROR < ${OutputDir}/output5a.1
${TestsDir}/Test5a secondPart > ${OutputDir}/output5a.2
grep --ignore-case ERROR < ${OutputDir}/output5a.2

./BuildTest ${TestsDir}/Test5b.cpp
echo "Running test 5b"
cp ${disk}.copy ${disk} 
${TestsDir}/Test5b > ${OutputDir}/output5b
grep --ignore-case ERROR < ${OutputDir}/output5b

./BuildTest ${TestsDir}/Test6.cpp
echo "Running test 6"
cp ${disk}.copy ${disk} 
${TestsDir}/Test6 > ${OutputDir}/output6
grep --ignore-case ERROR < ${OutputDir}/output6

./BuildTest ${TestsDir}/Test7.cpp
echo "Running test 7"
cp ${disk}.copy ${disk} 
${TestsDir}/Test7 1 > ${OutputDir}/output7.1
grep --ignore-case ERROR < ${OutputDir}/output7.1
${TestsDir}/Test7 2 > ${OutputDir}/output7.2
grep --ignore-case ERROR < ${OutputDir}/output7.2

./BuildTest ${TestsDir}/Test8.cpp
echo "Running test 8"
cp ${disk}.copy ${disk} 
${TestsDir}/Test8 > ${OutputDir}/output8
grep --ignore-case ERROR < ${OutputDir}/output8

./BuildTest ${TestsDir}/Test9.cpp
echo "Running test 9"
cp ${disk}.copy ${disk} 
${TestsDir}/Test9 > ${OutputDir}/output9
grep --ignore-case ERROR < ${OutputDir}/output9

./BuildTest ${TestsDir}/Test10.cpp
echo "Running test 10"
cp ${disk}.copy ${disk} 
${TestsDir}/Test10 1 > ${OutputDir}/output10.1
grep --ignore-case ERROR < ${OutputDir}/output10.1
${TestsDir}/Test10 2 > ${OutputDir}/output10.2
grep --ignore-case ERROR < ${OutputDir}/output10.2
${TestsDir}/Test10 3 > ${OutputDir}/output10.3
grep --ignore-case ERROR < ${OutputDir}/output10.3

./BuildTest ${TestsDir}/Test11.cpp
echo "Running test 11"
cp ${disk}.copy ${disk} 
${TestsDir}/Test11 > ${OutputDir}/output11
grep --ignore-case ERROR < ${OutputDir}/output11

